package com.drama.api.sys.log.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.drama.api.base.Constants;
import com.drama.api.sys.log.dao.SysLogDao;
import com.drama.api.sys.log.domain.po.SysLogPO;
import com.drama.api.sys.log.domain.vo.SysLogSearchVO;
import com.drama.api.sys.log.domain.vo.SysLogVO;
import com.drama.api.sys.log.service.ISysLogService;
import com.drama.api.task.SysLogThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
@Transactional
@Slf4j
public class SysLogServiceImpl implements ISysLogService {

    @Autowired
    private SysLogDao sysLogDao;


    @Override
    public List<SysLogVO> getList(SysLogSearchVO searchVO) {
        return sysLogDao.getList(searchVO);
    }

    @Override
    public void clear() {
        Example example=new Example(SysLogPO.class);
        sysLogDao.deleteByExample(example);
        new SysLogThread(sysLogDao, Constants.SYS_LOG_MODULE[5],"清除系统操作日志", (String) StpUtil.getLoginId()).start();

    }
}